package GUI.view;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import twaver.TWaverUtil;
import GUI.view.outlook.FreeListPane;
import GUI.view.outlook.FreeMenuBar;
import GUI.view.outlook.FreeOutlookPane;
import GUI.view.outlook.FreeUtil;


public class WDTShell extends JFrame{

	 private final String menuBarXML = "/menubar.xml";
	    private final String toolbarXML = "/toolbar.xml";
	    private final String outlookPaneXML = "/outlook.xml";
	    private final ActionListener defaultAction = new ActionListener() {

	        @Override
			public void actionPerformed(final ActionEvent e) {
	            final String command = e.getActionCommand();
	            //command(command);
	        }
	    };
	    private final String productName = "WDT";
	    private final String companyName = "ENSEEIHT";
	    private final FreeMenuBar menubar = FreeUtil.loadMenuBar(menuBarXML, defaultAction);
	    private final JPanel contentPane = new JPanel();
	    private final FreeListPane shortcutPane = new FreeListPane();
	    private final FreeOutlookPane outlookPane = new FreeOutlookPane(shortcutPane);
	    private final JPanel mainPane = new JPanel();
	   private final JPanel homePage = new JPanel();
	   private  final JPanel centerPane = new JPanel(new BorderLayout());

	    public WDTShell() {
	        initSwing();
	        initOutlookPane();
	        
	       
	        
	    }

	    private void initSwing() {
	        this.setTitle(productName + " v3.0 [" + companyName + "]");
	        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	        this.setSize(1024, 768);
	        this.setIconImage(TWaverUtil.getImage("/free/test/logo.png"));

	        this.setContentPane(contentPane);
	        contentPane.setLayout(new BorderLayout());
	        contentPane.add(menubar, BorderLayout.NORTH);

	       
	        centerPane.setLayout(new BorderLayout());
	        centerPane.setOpaque(true);
	        centerPane.setBackground(FreeUtil.CONTENT_PANE_BACKGROUND);
	        centerPane.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
	        //centerPane.add(shortcutPane, BorderLayout.EAST);
	        mainPane.setLayout(new BorderLayout());
	        mainPane.add(homePage,BorderLayout.CENTER);
	        centerPane.add(outlookPane, BorderLayout.WEST);
	        contentPane.add(centerPane, BorderLayout.CENTER);
	        centerPane.add(mainPane, BorderLayout.CENTER);
	        outlookPane.setMainPane(mainPane);
	    }

	    private void initOutlookPane() {

	        FreeUtil.loadOutlookPane(outlookPaneXML, outlookPane);
	    }

	    public static void main(final String[] args) {
	        SwingUtilities.invokeLater(new Runnable() {

	            @Override
				public void run() {
	                //FreeUtil.setupLookAndFeel();
	                final WDTShell shell = new WDTShell();
	                shell.setVisible(true);
	            }
	        });
	    }
}
